/******************************************************************
 * @version      : 1.0
 * @Author       : zhl
 * @Date         : 2023-03-16 09:41:33
 * @LastEditors  : zhl
 * @E-Mail       : zhll168@163.com
 * @Description  : 业务描述
 ******************************************************************/

#ifndef __NET_MANAGER_H__
#define __NET_MANAGER_H__

#include <memory>
#include "TCPInterface.h"
#include "CConfigManager.h"

typedef enum {
    WORKING_MODE_CLIENT = 0,
    WORKING_MODE_SERVER = 1
}WORKING_MODE;

class NetManager
{
private:
    /* data */
    static NetManager  c_tcp_manager;
    struct mg_mgr c_mgr;
    std::shared_ptr<TCPInterface> c_tcp_if;

public:
    NetManager(/* args */);
    ~NetManager();

    static NetManager& getInstance();

    int  connect();
    int  init(std::weak_ptr<CConfigManager> cm, const char* ip, uint16_t port, WORKING_MODE mode = WORKING_MODE_SERVER);
    int  send(const char *buf, int len);
    void close();

};



#endif /* __TCP_MANAGER_H__ */